package com.example.administrator.housepeasshop.utils;

import android.graphics.Bitmap;

import com.squareup.okhttp.Request;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.BitmapCallback;
import com.zhy.http.okhttp.callback.StringCallback;

/**
 * Created by Administrator on 2016/5/9.
 */
public class UtilsClassHttp {
    private static String mContent;
    private static Bitmap mBitmap;

    /*
    * 下载文本
    * */
    public static String OkHttpDownloadText(String path)
    {
        OkHttpUtils.get().url(path).tag("get").build().execute(new StringCallback() {
            @Override
            public void onError(Request request, Exception e) {

            }

            @Override
            public void onResponse(String response) {
                mContent=response;
            }
        });
        return mContent;
    }

    /*
    * 图片加载
    * */
    public static Bitmap OkHttpDownloadBitmap(String path)
    {
        OkHttpUtils.get().url(path).tag("image").build().execute(new BitmapCallback() {
            @Override
            public void onError(Request request, Exception e) {

            }

            @Override
            public void onResponse(Bitmap response) {
                mBitmap=response;
            }
        });
        return mBitmap;
    }
}
